The present invention relates to data processing in general and, more particularly, to methods, systems, and computer program products for monitoring program code memory usage. Object oriented programming is a well-known software application development technique that employs collections of objects or discrete modular data structures that are identified by so called references. More than one reference can identify the same object. The references can be stored in the application variables and within the objects, forming a network of objects and references, known as the reference graph. The objects are created dynamically during the application execution, and are contained in a memory structure referred to as a heap.
Many object oriented programming languages, such as JAVA®, Eiffel, and C sharp C#), employ automatic memory management, popularly known as garbage collection. Automatic memory management is an active component of the runtime system associated with the implementation of the object oriented language, which removes unneeded objects from the heap during the application execution. An object is unneeded if the application will no longer use it during its execution. A common way of determining at least a substantial subset of the unneeded objects is to determine so called “liveness” of all objects in the heap. An object is defined as “live” if there exists a path of references starting from one of the application variables, and ending at the reference to the given object. A path of references is defined as a sequence of references in which each reference with the exception of the first reference in the sequence is contained within the object identified by the previous reference in the sequence.
A frequent problem appearing in object oriented applications written in languages with automatic memory management is that some objects due to the design or coding errors remain live, contrary to the programmer's intentions. Such objects are called lingering objects. Lingering objects tend to accumulate over time, clogging the heap and causing multiple performance problems, eventually leading to the application crash.
To detect the lingering objects, programmers in the development phase of the application life-cycle employ memory debugging or memory profiling tools. In one widely practiced debugging methodology, the tool produces a heap dump which serves as a baseline snapshot that illustrates the objects residing in the heap at the given time. A set of test inputs is then run through the program and the tool produces a second snapshot of the heap which illustrates the objects residing in the heap at the second time. The programmer then compares the two snapshots to determine which objects are accumulating over time. By analyzing the reference graphs contained in the heap dumps, and using his/her skills and the knowledge of the program logic, the programmer can determine which objects are lingering, and, what is even more important, why they stay alive. Then the programmer can proceed with fixing the application program in such a way that no more reference paths to the lingering objects can be found by the garbage collector. Despite the acceptance of existing approaches to finding lingering objects, they may be tedious to use, and may not easily scale in a production environment, where heap sizes can be of order of gigabytes.
U.S. Patent Publication No. 2004/0181782 discusses a system and method for optimizing memory usage by locating lingering objects. U.S. Pat. No. 6,167,535 discusses object heap analysis techniques for discovering memory leaks and other run time information. U.S. Pat. No. 6,694,507 discusses a method and apparatus for analyzing performance of object oriented programming code. U.S. Pat. No. 6,434,575 discusses a method of instrumenting garbage collection generating a trace file making a single pass analysis of object heap. The disclosures of U.S. Patent Publication No. 2004/0181782, U.S. Pat. No. 6,176,535, U.S. Pat. No. 6,694,507, and U.S. Pat. No. 6,434,575 are hereby incorporated herein in their entirety by reference.
Notwithstanding the systems and methods discussed above, there continues to exist a need for methods, systems, and computer program products providing monitoring of object oriented program code memory usage.